#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x){
	x=0;int f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	x*=f;
}
const int N=1e5+5;
int n,b[N];
vector<int> a[N]; 
bool ans[N<<2];
int f[64];
void outans(){
	int fir=4e5;
	while(!ans[fir]) --fir;
	while(~fir) putchar(ans[fir--]^48);
}
int main(){
	freopen("mcmf.in","r",stdin);
	freopen("mcmf.out","w",stdout);
	read(n);
	bool sub=1,sub2=1;
	for(int i=1;i<=n;++i){
		int k;read(k);
		a[i].resize(k);
		for(int j=0;j<k;++j) read(a[i][j]),--a[i][j],sub2&=(a[i][j]<=5);
		sub&=(k==1);
	}
	if(sub){
		for(int i=1;i<=n;++i) b[i]=a[i][0];
		sort(b+1,b+n+1);
		for(int i=1,w=-1;i<=n;++i){
			w=max(w+1,b[i]);
			ans[w]=1;
		}
		return outans(),0;
	}else if(sub2){
		memset(f,0x3f,sizeof(f));
		f[0]=0;
		for(int i=1;i<=n;++i){
			int now=0;
			for(int j:a[i]) now|=1<<j;
			for(int j=63;~j;--j){
				++f[j];
				for(int k=j;k;k=(k-1)&j)
					if(k>=now) f[j]=min(f[j],f[j^k]);
			}
		}
		int mi=1e9,id;
		for(int i=0;i<64;++i) if(f[i]<mi) mi=f[i],id=i;
		for(int i=6;i<=mi+5;++i) ans[i]=1;
		for(int i=0;i<6;++i) if((id>>i)&1) ans[i]=1;
		return outans(),0;
	}
	return 0;
}

